package vn.raz.brainnydefense;

import vn.raz.brainnydefense.ultility.Assets;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.assets.AssetManager;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.GLCommon;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.math.Vector3;

public class LoadScreen implements Screen{

	MainGame game;
	OrthographicCamera guiCam;
	SpriteBatch batcher;
	Vector3 touchpos;
	Texture load0;
	Texture load1;
	Texture scene;
	public static int count;
	
	public LoadScreen(MainGame game){
		this.game = game;
		guiCam = new OrthographicCamera(480, 800);
		guiCam.position.set(480 / 2, 800 / 2, 0);
		batcher = new SpriteBatch();
		touchpos = new Vector3();
		count = 1;
		load();
	}
	
	public void load(){
		Assets.load();
	}
	
	public void reset(){
		count = 0;
	}
	
	public void update(float delta){
		count ++;
		switch(count){
			case 1: 
					Assets.load();
					break;
			case 2: 
//					Assets.loadItemPandora();
					break;
			case 3: 
//					Assets.loadStageClassic();
					break;
		}
		if(count==4){
			game.createScreen();
			game.setScreen(game.gamescreen);
			
//			game.testscreen.setKindBonus(1);
//			game.setScreen(game.testscreen);
//			game.setScreen(game.shopscreen);
//			game.setScreen(game.menuscreen);
			
			//if (Settings.musicEnabled) Assets.main_music.play();
		}
	}
	
	public void draw(float delta){
		GLCommon gl = Gdx.gl;
		gl.glClearColor(0, 0, 0, 0);
		gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
		guiCam.update();
		batcher.setProjectionMatrix(guiCam.combined);
		batcher.enableBlending();
		batcher.begin();
//		batcher.draw(scene, 0, 0);
//		int q  = (int) ((210/100)*(Assets.manager.getProgress()*100));
//		batcher.draw(load1, 275+q, 200);
//		batcher.draw(load0, 260, 150);
		batcher.end();
	}
	
	@Override
	public void render(float delta) {
		update(delta);
		draw(delta);
	}

	@Override
	public void resize(int width, int height) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void show() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void hide() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void pause() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void resume() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub
		
	}
	
}
